<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class UserLabelRelation extends Model
{
    use HasFactory;
    use PimpableTrait;
//    use SoftDeletes;

    /**
     * 可执行搜索的字段
     */
    protected $searchable = [
        'user_id',
        'label_id',
    ];

    /**
     * 可批量赋值字段
     */
    public $fillable = [
        'user_id',
        'label_id'
    ];

    /**
     * 默认使用倒叙的字段
     */
    protected $defaultSortCriteria = [
        'id,desc',
    ];

    /**
     * 用户标签关联对应用户表
     */
     public function user()
     {
        return $this->belongsTo(User::class,'user_id','id');
     }

    /**
     * 用户标签关联对应标签表
     */
    public function userlabels()
    {
        return $this->belongsTo(UserLabel::class,'label_id','id');
    }

}
